// 定义记分牌的class
class ScorePanel{
  // 记录分数和等级
  score=0;
  level=1

  // 设置一个等级限制
  maxLevel: number
  upScore: number
  // 分数和等级所在元素
  scoreEle: HTMLElement
  levelEle: HTMLElement
  constructor(maxLevel:number = 10,upScore:number = 5) {
    this.scoreEle = document.getElementById('score')!
    this.levelEle = document.getElementById('level')!
    this.maxLevel = maxLevel
    this.upScore = upScore
  }

  // 设置加分方法
  addScore(){
    this.scoreEle.innerHTML = ++this.score + ''
    // 判断分数是多少
    if(this.score % this.upScore === 0) {
      this.levelUp()
    }
  }

  // 提升等级
  levelUp(){
    if(this.level < this.maxLevel){
      this.levelEle.innerHTML = ++this.level + ''
    }
    
  }
}
export default ScorePanel